home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6600 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  49 lines

  1. Newsgroups: comp.lang.c
  2. Path: uu4news.netcom.com!friend!news
  3. From: rich@kastle.com (Richard Krehbiel)
  4. Subject: Re: Watch out!  C "gotcha!"
  5. Message-ID: <1996Feb15.124111.8122@friend.kastle.com>
  6. Sender: news@friend.kastle.com (News)
  7. Reply-To: rich@kastle.com
  8. Organization: Kastle Development Associates
  9. X-Newsreader: Forte Free Agent 1.0.82
  10. References: <4fthhh$7th@blackice.winternet.com>
  11. Date: Thu, 15 Feb 1996 12:41:58 GMT
  12.  
  13. mschwarz@winternet.com (Michael Schwarz) wrote:
  14.  
  15. >Many of you may already know this, but even after ten years of coding
  16. >in C, this took my by surprise at first.  A co-worker and I were looking
  17. >at some library C code where I work and we noticed that the "default"
  18. >clause of one of the switches was misspelled as "defalt."
  19.  
  20. Yep.  I've done that.
  21.  
  22. I recently encountered the following bug:
  23.  
  24. enum opcode code;
  25.  
  26. switch(code)
  27. {
  28. case OC_STAT:
  29.    ...
  30.    break;
  31. case OC_RECID:
  32.    ...
  33.    break;
  34. OC_SUP:    /* Oh, look - I forgot to type 'case'.  :-( */
  35.    ...
  36.    break;
  37. case OC_IND:
  38.    ...
  39.    break;
  40. }
  41.  
  42. This code has been compiling and working well until a recent revision
  43. to the data generator started producing OC_SUP.
  44.  
  45. --
  46. Richard Krehbiel, Kastle Systems, Arlington VA USA
  47. rich@kastle.com (work) or richk@mnsinc.com (personal)
  48.  
  49.